<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script>
        function run1(x) {
            if (x.value.length!=0){
              document.getElementById(x.id+"Msg").innerHTML="";
            }else {
                document.getElementById(x.id+"Msg").innerHTML="请输入用户名";
            }
        }
        function run2(x) {
            if (x.value.length!=0){
                document.getElementById(x.id+"Msg").innerHTML="";
            }else {
                document.getElementById(x.id+"Msg").innerHTML="请输入密码";
            }
        }
    </script>
</head>
<body>
用户名:<input id="username" type="text" onkeyup="run1(this)"/>
<font id="usernameMsg">请输入用户名</font>
<br/>
密码:<input id="pwd" type="password" onkeyup="run2(this)"/>
<font id="pwdMsg">请输入密码</font>
</body>
</html>